package com.oa.modules.approvalsec1.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oa.modules.approvalsec1.entity.ToDoImmediatelyEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 立即办
 *
 * @author jiangwei
 * @email 785297226@qq.com
 * @date 2021-03-22 10:03:27
 */
@Mapper
public interface ToDoImmediatelyDao extends BaseMapper<ToDoImmediatelyEntity> {


    /**
     * 查询总条数
     *
     * @author jiangwei
     * @email 785297226@qq.com
     * @date 2021-03-22 10:03:27
     * @Description 查询分页数据
     */
    @Select("<script>" +
            "SELECT COUNT( 1 ) FROM (" +
            "select t1.* from to_do_immediately t1  " +
            "where 1=1 " +
            "<if test = 'params != null '> "+
            "and t1.`STATUS` = #{params.status} " +
            "<if test='params.companyName != null'>and t1.company_name LIKE '%${params.companyName}%'  </if> " +
            "<if test='params.createOper != null'>and t1.create_oper = #{params.createOper} </if> " +
            ") </if> TOTAL" +
            "</script>")
    long findPage(@Param("params") Map<String, Object> params);

    /**
     * 查询分页数据
     *
     * @author jiangwei
     * @email 785297226@qq.com
     * @date 2021-03-22 10:03:27
     * @Description 查询分页数据
     */
    @Select("<script>" +
            "select t1.* from to_do_immediately t1 " +
            "where 1=1 " +
            "and t1.`STATUS` = #{params.status} " +
            "<if test='params.companyName != null'>and t1.company_name LIKE '%${params.companyName}%'  </if> " +
            "<if test='params.createOper != null'>and t1.create_oper = #{params.createOper} </if> " +
            "ORDER BY t1.CREATE_DATE desc" +
            "</script>")
    List<ToDoImmediatelyEntity> findRecords(IPage<ToDoImmediatelyEntity> page, @Param("params") Map<String, Object> params);


    /**
     * 查询未完成的帮办任务
     *
     * @author jiangwei
     * @email 785297226@qq.com
     * @date 2021-03-22 10:03:27
     * @Description 查询未完成的帮办任务
     */
    @Select("<script>" +
            "select t1.* from assist_in_managing t1 " +
            "where 1=1 " +
            "and t1.is_assign = '1'  " +
            "and t1.progress_bar = '1'   " +
            "ORDER BY t1.CREATE_DATE desc" +
            "</script>")
    List<ToDoImmediatelyEntity> queryIsAssign();

}
